package org.example.multiThreading.ThreadMethod;

public class MyThreadJoin {
    public static void main(String[] args) throws InterruptedException {
        TestRunable runable = new TestRunable();
        Thread thread = new Thread(runable);
        thread.start();

        //允许其他线程加入到当前线程中。当某线程调用该方法时，加入并阻塞当前线程，直到加入的线程执行完毕，当前线程才继续执行
        thread.join();

        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName()+"-"+i);
        }
    }
}

class TestRunable implements Runnable{

    public void run(){
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName()+"-"+i);
        }
    }

}
